﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using PSTS.UI.Views.Pages;
using PSTS.UI.ViewModels;
using PSTS.UI.Commands;

namespace PSTS.UI.Views
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            try
            {
                InitializeComponent();

                var viewModel = new MainWindowViewModel();
                DataContext = viewModel;

                CommandBindings.Add(new CommandBinding(PSTSCommands.StartTestChapterSelectionCommand,
                    viewModel.StartTestChapterSelectionCommand_Executed,
                    viewModel.StartTestChapterSelectionCommand_CanExecute));
                CommandBindings.Add(new CommandBinding(PSTSCommands.LoginCommand,
                    viewModel.LoginCommand_Executed,
                    viewModel.LoginCommand_CanExecute));
            }
            catch (Exception e)
            {
                Exception i = e;
                string s="";
                while (i != null)
                {
                    s += i.Message;
                    i = i.InnerException;
                }
                MessageBox.Show(s);
            }
        }

        private void About_OnClick(object sender, RoutedEventArgs e)
        {
            MessageBox.Show(
                "PSTS v1.0\nНавчальна система, яка дає можливість проходити тестування із заданих предметів.\nВсі права захищені.",
                "Про PSTS");
        }
    }
}
